<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "bonus_type".
 *
 * @property integer $id
 * @property string $name
 * @property string $money
 * @property string $min_amount
 * @property integer $type
 * @property integer $started_at
 * @property integer $ended_at
 * @property string $min_goods_amount
 * @property integer $created_at
 * @property integer $updated_at
 * @property integer $created_by
 * @property integer $updated_by
 *
 * @property Bonus[] $bonuses
 */
class BonusType extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'bonus_type';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'money', 'started_at', 'ended_at', 'created_at', 'updated_at', 'created_by', 'updated_by'], 'required'],
            [['money', 'min_amount', 'min_goods_amount'], 'number'],
            [['type', 'started_at', 'ended_at', 'created_at', 'updated_at', 'created_by', 'updated_by'], 'integer'],
            [['name'], 'string', 'max' => 64],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'money' => 'Money',
            'min_amount' => 'Min Amount',
            'type' => 'Type',
            'started_at' => 'Started At',
            'ended_at' => 'Ended At',
            'min_goods_amount' => 'Min Goods Amount',
            'created_at' => 'Created At',
            'updated_at' => 'Updated At',
            'created_by' => 'Created By',
            'updated_by' => 'Updated By',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getBonuses()
    {
        return $this->hasMany(Bonus::className(), ['bonus_type_id' => 'id']);
    }
}
